<h1>JRobin-MRTG</h1>
<p>Once upon a time Tobi Oetiker created <b>The Multi Router Traffic Grapher (MRTG)</b>:</p>
<blockquote style="MARGIN-RIGHT: 0px">
<p><em>...a tool to monitor the traffic load on network-links. MRTG generates HTML pages containing graphical images which provide a LIVE visual representation of this traffic</em>... <em>MRTG is based on Perl and C and works under UNIX and Windows NT...</em> </p></blockquote>
<p>MRTG runs as a scheduled task: <em>cron</em> daemon is used on UNIX systems to run MRTG each 5 minutes, for example. MRTG creates traffic graphs as PNG files embedded in simple HTML pages. All pages (with daily, weekly, monthly and yearly graphs) are created in a single directory backed by (Apache) web server: you can watch your Internet traffic (almost) LIVE by means of any web browser.</p>

<p>Under the hood, you'll find that Tobi's MRTG uses some kind of RRD files to store traffic data (MRTG native format or RRDTool file format). So, I thought, it should be possible to create a similar application in pure Java using JRobin. <strong>I did not want to compete with MRTG</strong>, <strong>I just wanted to prove that JRobin is useful for the same purposes as Tobi's famous RRDTool and MRTG</strong>. But if you want to measure your internet traffic in a simple and efficient way, you'll be probably satisfied.</p>
<p>So, JRobin-MRTG is finally here. It consists of two 
separate applications: the client and the server one. These two applications 
communicate through protocol. You can run one server application and as many client applications on as many different machines as you want. Client applications are used to control the server: to remotely add, edit, update or delete monitored network interfaces and to request specific traffic graphs.</p>
<h2>JRobin-MRTG server</h2>
<p>Server application is used to:</p>
<ul>
<li>collect information about Internet traffic load 
  from various network devices supporting SNMP protocol (routers, switches, 
  network servers);   
<li>store traffic information into JRobin RRD files; 
<li>create graphs and other information for any number of JRobin-MRTG client applications;</li>
</ul>
<p>To run server application, issue the following command from the command line:</p><pre>
java -jar mrtg-server-[version].jar
</pre>
<p>The command line could be more complex if you don't have X-server (windows) installed and you don't want to be interrupted once you log out (common situation on many network servers). In that case use the following command:</p><pre>
nohup java -Djava.awt.headless=true -jar mrtg-server-[version].jar &gt; /dev/null 2&gt;&amp;1 &amp;
</pre>
<p>The server application uses port 35353 to communicate with unlimited number of client applications. It can be reached with any JRobin-MRTG client from the internet (unless firewall blocks XMLRPC communication between clients and the server application). If you want to restrict access to the server application, add IP addresses of trusted clients to the command line. For example:</p><pre>
java -Djava.awt.headless=true -jar mrtg-server-[version].jar 192.168.1.23 192.168.1.24 </pre>
<p>When server application is run for the first time, <strong>mrtg</strong> directory will be created in your <strong>$HOME</strong> directory. Newly created directory has two subdirectories: <strong>conf</strong> and <strong>rrd</strong>. The first directory (<strong>conf</strong>) containts a single XML file - <strong>hardware.dat. </strong> It holds complete information about monitored internet devices and interfaces. The second directory (<strong>rrd</strong>) contains RRD files, one file per each monitored network interface. If you monitor internet traffic through interface <em>Serial2</em> on the router <em>belgrade2.eunet.yu</em>, you will find a file named <em>Serial2@belgrade2.eunet.yu.rrd</em><em> </em> in this directory.</p>
<p>Server application requires the following libraries to be present:</p>
<ul>
<li>Jakarta XML-RPC library for communication between the 
  server and client applications; 
  
<li>SNMP library for communication with network devices 
  (actual traffic load measurement); 
  
<li>JFreeChart library for graph creation; 
  
<li>JRobin library for RRD files manipulation and graph creation.</li>
</ul>
<p>All requested libraries can be found in the <strong>libs</strong> directory of this distribution.</p>
<h2>JRobin-MRTG client</h2>
<p>Client application is used to control the work of the server application. Java swing library is used to create the client UI. This UI is used to:</p>
<ul>
<li>remotely add/edit/update/delete monitored network 
  devices (routers, switches, network stations) and associated network 
  interfaces; 
  
<li>remotely create daily, weekly, monthly, yearly and 
  custom-period traffic graphs on the server side, bring them to the client side 
  and show them on the screen; 
  
<li>store these graphs in PNG files.</li>
</ul>
<p>Client application requires already mentioned Jakarta XML-RPC library for communication with the server (it can be found in the <strong>libs</strong> directory of this distribution). To run client application issue the following command from the command line:</p><pre>
java -jar mrtg-client-[version].jar
</pre>
<p>You will be asked to specify the address of the host on which JRobin-MRTG server application is running. Once you are connected, you will see the client application's UI.</p>
<p>Client UI has two preview panes: the left (tree) pane 
contains information about monitored network interfaces. The right (text) pane contains information about the selected element of the tree on the left side. Network devices (like routers and switches) are commonly denoted as 'routers'.</p>
<p><strong>Note: </strong> Displayed information is not constantly updated! It gets updated whenever you add, update or remove a single router or its interface. If you want to refresh the displayed data so that it corresponds with the actual data on the server, right click anywhere on the client or choose <em>Reload data from MRTG host </em> from the <em>MRTG</em> menu. However, all kind of graphs are always generated using the latest available information from the server. And the graphs are constantly refreshed if necessary. They are as LIVE as Tobi's MRTG graphs are :)</p>
<p>In my humble opinion, client UI is simple and intuitive. You should have no problem to start monitoring your internet traffic load in a matter of minutes. I will explain only a few of the most interesting operations here.</p>
<h2>How to add a router</h2>
<ul>
<li>From the client menu, choose <em>Router actions / Add router...</em> New router dialog 
  appears. 
  
<li>Supply router address (like <em>belgrade2.eunet.yu</em> or 123.000.111.222). 
  
<li>Supply router <em>community</em>. Communities are something like passwords 
  for SNMP access to the router. If not sure about which community to use, ask 
  your network administrator. 
  
<li>Supply some description of the router if necessary 
  for future reference. 
  
<li>Checkbox <em>Active</em> should 
  be already checked by default. 
  
<li>Click OK. Newly defined router appears on the left side of the screen.</li>
</ul>
<h2>How to add a network interface</h2>
<ul>
<li>Select the router with the desired interface in the 
  tree pane. 
  
<li>From the menu, choose <em>Interface actions / Add interface... </em>New interface 
  dialog appears. 
  
<li>Select the desired interface from the list of all 
  available interfaces on the router. 
  
<li>Specify description if necessary for future 
  reference. 
  
<li>Specify sampling interval in seconds. It represents 
  the amount of time that should pass before the server applications checks the 
  traffic load for the specific interface on the router once again. Valid values 
  are between 10 seconds and 600 seconds (10 minutes). 
  
<li>Checkbox <em>Active</em> should 
  be already checked by default. 
  
<li>Click OK.</li>
</ul>
<p>Newly defined interface appears on the left side of the screen, probably with [-1] number added to its name. It means that MRTG server still does not know the real number of the interface on the router. But if you reload data from MRTG sever a few seconds later, you will probably see some positive number instead of [-1]. It means that the new interface exists on the router. You can be sure that the traffic monitoring process has started successfully.</p>
<p>I have tried to make JRobin-MRTG as clever as I could - if router gets reconfigured so that its interfaces change its corresponding interface numbers, JRobin-MRTG server application will notice this and update interface numbers on the fly.</p>
<h2>How to create traffic graphs </h2>
<ul>
<li>Select network interface you want to create graph 
  for. 
  
<li>Chose the desired graph type from the <em>Interface actions </em>menu. The following graphs can be 
  created with a single click: daily, weekly, monthly, yearly, last 24 hours and 
  custom-period graphs. The graph appears in the new frame. 
  
<li>Click on the <em>Save</em> button to the right of the graph to save it in a PNG file format.</li>
</ul>
<p><strong>Note: </strong></p>
<ul>
<li>Graphs starting in the past and ending in the future 
  (graph for the current day, week, month and year, for example) are 
  automatically refreshed each 5 minutes. You can watch the growth of your 
  current daily graph - LIVE. 
  
<li>Graphs are created on the server side, not on the 
  client side. Future versions of JRobin-MRTG might change this. But, at this 
  moment, graphs are serialized on the server side and transmitted to the client 
  via XML-RPC protocol. 
  
<li>You can open as many graph frames as you wish. All 
  graphs will be updated simultaneously, if necessary. 
  
<li>Use custom graphs to create traffic graphs for arbitrary time intervals.</li>
</ul>
<p>Have fun! :)</p>